from selenium.webdriver.common.by import By


from Driver.Driver import MDriver

class LogInFace:
    driver=''
    alert=''
    url=''
    def __init__(self):
        self.driver=MDriver.driver
        self.url="http://127.0.0.1:9580/sign-in.html"

    # 进入登陆界面
    def Come(self):
        self.driver.get(self.url)
    # 检测界面元素
    def QFind(self,str):
        self.driver.find_element(By.CSS_SELECTOR,str)
    def Face(self):
        # 检测图标
        self.QFind("body > div.page.page-center > div > div > div:nth-child(1) > div > div.text-center.mb-4 > img")
        # 检测用户登录文字
        self.QFind("body > div.page.page-center > div > div > div:nth-child(1) > div > div.card.card-md > div > h2")
        # 检测用户名、输入框、提示灯等登陆元素
        self.QFind("#signInForm > div.mb-3 > label")
        self.QFind("#username")
        self.QFind("#signInForm > div.mb-2 > label")
        self.QFind("#password")
        # 检测查看密码按钮
        self.QFind("#password_a > svg")
        # 检测登陆按钮
        self.QFind("#submit")
        # 检测注册按钮
        self.QFind("body > div.page.page-center > div > div > div:nth-child(1) > div > div.text-center.text-muted.mt-3 > a")
        # 检测图画
        self.QFind("body > div.page.page-center > div > div > div.col-lg.d-none.d-lg-block > img")


    # 输入用户名
    def LogInScanfName(self,name):
        self.driver.find_element(By.CSS_SELECTOR,"#username").send_keys(name)
    # 输入密码
    def LogInScanfPass(self,Pass):
        self.driver.find_element(By.CSS_SELECTOR,"#password").send_keys(Pass)
    # 清空用户名
    def DeleteName(self):
        self.driver.find_element(By.CSS_SELECTOR,"#username").clear()
    # 清空密码
    def DeletePass(self):
        self.driver.find_element(By.CSS_SELECTOR,"#password").clear()
    # 点击登录
    def LogInTake(self):
        self.driver.find_element(By.CSS_SELECTOR,"#submit").click()
    # 跳转到注册界面
    def LogInGoToRego(self):
        self.driver.find_element(By.CSS_SELECTOR,"body > div.page.page-center > div > div > div:nth-child(1) > div > div.text-center.text-muted.mt-3 > a").click()






